import Base from '../main/Base';
import Fs from './FundStatus';
export default class progress {
    constructor(data) {
        this.data = data;
        this.cmp = {
            fundStatus: new Fs(data)
        }
        this.sts = {
            congrats: 'congrats'
        }
        this.fakeClass=data['is_full']?"show":"";
    }

    static renderOut() {
        let _ = require('../middleware/utils');
        let that = this;
        _.get('http://54.223.238.147:910/get_photo_detail_history', function (data) {
            var pd = JSON.parse(data);
            if (pd && pd['is_full']) {
                console.log(pd['is_full']);
                _.$(_.e(that.sts.congrats)).classList.add('show');
            }
            if (pd.status !== 1) {
                Base.render(`<div>${pd.msg}</div>`, '.progress_mom_placeholder', 'inner');
            }
            else
                Base.render(new progress(pd), '.progress_mom_placeholder', 'inner');
        });
    }

    render() {
        return `
        <div class="stickTop">
            <div class="banner_stickTop_img"></div>
            <div class="fund_stickTop_container">
                <div class="columns"><div class="done_container_fund">${this.data['sum_number']}(人)<div class="suffix_done_helper">已拍书捐爱心
</div></div></div>
                <div class="columns"><div class="predict_container_fund">30000(元)<div class="suffix_predict_helper">预计筹款数目</div></div></div>
            </div>
        </div>
        <div class="eventDetail show">
          <!--  <div class="stick_eventDetail_container">
                <div class="icon_eventDetail_img"></div>
                <span class="title_eventDetail_text">活动详情</span>
                <div class="arrow_eventDetail_img"></div>
            </div>-->
            <div class="intro_eventDetail_text">
                           你拍下一本书籍封面，宁波印象城会代你捐1元送给偏乡孩子作为读书基金。收集超过3万本，我们将通过狮子会向江北甬城学校捐献价值3万元书资。

            </div>
        </div>
        <div class="loveFront">
          <div class="stick_loveFront_container">
                <div class="icon_loveFront_img"></div>
                <span class="title_loveFront_text">爱心前线</span>
            </div>
            ${this.cmp.fundStatus.render()}
        </div>
        <div class="congrats ${this.fakeClass}">
    <div class="reach_congrats_img"></div>
    <div class="btn_congrats_img"></div>
</div>
        `;
    }

    listen() {
        return {
            momId: 'body',
            uid: '.btn_congrats_img',
            ontouchstart(binded, evt){
                let b = document.querySelector('.congrats');
                b.classList.remove('show');
                evt.stopPropagation();
            }
        }
    }
}


let _ = require('../middleware/utils');
_.e= _.str2class;
    _.get('http://54.223.238.147:910/get_photo_detail_history', function (data) {
    var pd = JSON.parse(data);
    if (pd.status !== 1) {
        Base.render(`<div>${pd.msg}</div>`, 'body', 'inner');
    }
    else
        Base.render(new progress(pd), 'body', 'inner');
});
